/**
 * Created by Richard Radlherr.
 * Date: 06.07.2006 16:58
 */

using System;
using System.Collections.Generic;
using CsGL;
using CsGL.OpenGL;
using TagTool.Core;
using TagTool.OpenGL;
using TagTool.GraphicTypes;

namespace TagTool.Nodes.Graphic
{

	public class Scene : BaseNode
	{

		InputSlot tagList; // the taglist
		OutputSlot shape; // the complete scene as shape
		
		private InputSlot angle;
		private InputSlot axis;
		private InputSlot translate;
		private InputSlot scale;
		
		public Scene() : base()
		{
			Name = "Scene";
			
			tagList = new InputSlot(this, "Taglist in", new List<Shape>());
			shape = new OutputSlot(this, "Scene", typeof(TagTool.GraphicTypes.Scene));
			shape.Value = new TagTool.GraphicTypes.Scene();
			
			angle = new InputSlot(this, "Angle", 0.0);
			angle.ParseCallback = ParseHelper.ParseDouble;
			
			axis = new InputSlot(this, "Rotate", new PointD(0.0,1.0, 0.0));
			axis.ParseCallback = ParseHelper.ParseVector;
			
			translate = new InputSlot(this, "Translate", new PointD());
			translate.ParseCallback = ParseHelper.ParseVector;
			
			scale = new InputSlot(this, "Scale", new PointD(1.0, 1.0, 1.0));
			scale.ParseCallback = ParseHelper.ParseVector;
		}

		public override void Update(Object sender)
		{
			TagTool.GraphicTypes.Scene sc = (TagTool.GraphicTypes.Scene)shape.Value;
			sc.Shapes = (List<Shape>)tagList.Value;
			sc.Angle = (double)angle.Value;
			sc.Translate = (PointD)translate.Value;
			sc.Rotate = (PointD)axis.Value;
			sc.Scale = (PointD)scale.Value;
		}
		
		public override void Initialize() {
			shape.Value = new TagTool.GraphicTypes.Scene();
			Update(shape);
		}

		[NodeAttribute(SlotType.Input, Show = true, ValueTypeName = "List<double>")]
		public InputSlot TagList
		{
			get { return tagList; }
		}

		[NodeAttribute(SlotType.Output, Show = true)]
		public OutputSlot Shape
		{
			get { return shape; }
		}
		
	}
}
